import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../utils/resability.dart';

import '../bindings/app_routes.dart';

void showToast(String title, String message, {bool isError = false}) {
  Get.snackbar(
    title,
    message,
    backgroundColor: isError ? Colors.red : Colors.green,
    colorText: Colors.white,
    snackPosition: SnackPosition.BOTTOM,
    duration: const Duration(seconds: 2),
    animationDuration: const Duration(milliseconds: 500),
    margin: const EdgeInsets.all(10),
    borderRadius: 10,
    icon: Icon(isError ? Icons.error : Icons.check_circle, color: Colors.white),
  );
}

void showDialog(String title, String message, String routes) {
  Get.defaultDialog(
    title: title, // 弹窗标题
    titleStyle: TextStyle(
      fontSize: 18,
      fontWeight: FontWeight.bold,
      color: Colors.black87,
    ),
    middleText: message, // 弹窗内容
    middleTextStyle: TextStyle(fontSize: 14, color: Colors.grey[700]),
    backgroundColor: Colors.white, // 弹窗背景色
    radius: 12, // 弹窗圆角
    contentPadding: EdgeInsets.all(20), // 内容内边距
    actions: [
      ElevatedButton(
        onPressed: () {
          Get.offAllNamed(AppRoutes.login); // 关闭弹窗
          // 在这里添加确认按钮的逻辑
        },
        style: ElevatedButton.styleFrom(
          backgroundColor: bg_color, // 按钮背景色
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(8), // 按钮圆角
          ),
        ),
        child: Text('确认', style: TextStyle(color: Colors.white, fontSize: 14)),
      ),
    ],
  );
}
